var t,
  e = require("../../@babel/runtime/helpers/defineProperty"),
  a = require("../../res/www.a9a.cn.js"),
  o = getApp();
Page({
  data: {
    miao: 120,
    miao2: 120,
    f: "",
    RZindex: [],
    ss: "",
    tmpsfz: ["", ""],
    elsetmp: "",
    showModalC:
      "请填写征婚者本人手机号码、本人姓名、身份证号、本人头像，经公安库身份自动核对通过的才是真实资料\n\n如有第三方公安库收取核验费用的，无法通过的均为虚假资料，不予退款\n\n冒用TA人信息注册或转让自己征婚信息帐号的均属违法行为，承担相应法律责任，请你真诚征婚交友，违法必究",
    ifonLoad: !1,
  },
  onLoad: function (t) {
    var e = this,
      i = this;
    o.chklogin().then(function (n) {
      n
        ? (o.get_config("_ZEAI").then(function (t) {
            i.setData({
              color: t.color,
              rgbcolor: a.c16_rgb(t.color),
              siteName: t.siteName,
              WWW: o.WWW,
              cache_str: t.cache_str,
            });
          }),
          o.get_openid().then(function (a) {
            var n = t.f;
            i.setData({ f: n }),
              o.empty(n) ? (i.setData({ ifonLoad: !0 }), e.index()) : i.one(n);
          }))
        : wx.redirectTo({ url: "../login/login" });
    });
  },
  index: function () {
    var e = this;
    (t = wx.getStorageSync("COOK_U")),
      o.ajax({
        url: "my_cert.php",
        data: { submitok: "index", openid: t.openid },
        success: function (t) {
          1 == t.flag
            ? e.setData({ RZindex: t.RZindex, MB: t.MB })
            : wx.showModal({
                content: t.msg,
                confirmColor: e.data.color,
                confirmText: "朕知道了",
                showCancel: !1,
                success: function (t) {
                  wx.navigateBack();
                },
              }),
            wx.setNavigationBarTitle({ title: "诚信认证" });
        },
      });
  },
  certoneFn: function (t) {
    var e = t.currentTarget.dataset.f;
    a.empty(this.data.MB) || o.openSetting(this.data.MB),
      wx.navigateTo({ url: "cert?f=" + e });
  },
  one: function (e) {
    wx.showLoading({ title: "玩命加载中", mask: !0 });
    var a = this;
    (t = wx.getStorageSync("COOK_U")),
      o.ajax({
        url: "my_cert.php",
        data: { submitok: "one", f: e, openid: t.openid },
        success: function (t) {
          1 == t.flag
            ? (a.setData({
                ARR: t.ARR,
                kf_wxpic: t.kf_wxpic,
                kf_address: t.kf_address,
              }),
              wx.setNavigationBarTitle({ title: t.ARR.title }),
              "identity" == e && 1 == t.ARR.rz_mobile3
                ? wx.setNavigationBarColor({
                    backgroundColor: "#083BB1",
                    frontColor: "#ffffff",
                  })
                : "photo" == e &&
                  1 != a.data.ARR.rzflag &&
                  wx.setNavigationBarColor({
                    backgroundColor: "#0A183F",
                    frontColor: "#ffffff",
                  }),
              a.setData({ ifonLoad: !0 }))
            : (a.setData({ f: "alert" }),
              wx.showModal({
                content: t.msg,
                confirmColor: a.data.color,
                confirmText: "朕知道了",
                showCancel: !1,
                success: function (t) {
                  wx.navigateBack();
                },
              })),
            wx.hideLoading();
        },
      });
  },
  vipFn: function () {
    wx.navigateTo({ url: "../my_vip/my_vip" });
  },
  value_mobFn: function (t) {
    this.setData({ value_mob: t.detail.value });
  },
  getyzmFn: function (e) {
    var i = this.data.value_mob;
    if (a.ifmob(i)) {
      var n = this;
      (t = wx.getStorageSync("COOK_U")),
        o.ajax({
          url: "my_cert.php",
          data: { submitok: "ajax_get_verify", mob: i, openid: t.openid },
          success: function (t) {
            1 == t.flag
              ? (wx.showToast({ title: t.msg, icon: "none", mask: !0 }),
                n.setData({
                  ss: t.ss,
                  value_verify: "",
                  miao: n.data.miao2 - 1,
                }),
                (n.time = setInterval(function () {
                  n.setData({ miao: n.data.miao - 1 }),
                    0 == n.data.miao && clearInterval(n.time);
                }, 1e3)))
              : wx.showModal({
                  content: t.msg,
                  confirmColor: n.data.color,
                  confirmText: "朕知道了",
                  showCancel: !1,
                  success: function (t) {},
                });
          },
        });
    } else
      wx.showToast({
        title: "请输入正确的【手机号码】",
        icon: "none",
        mask: !0,
      });
  },
  submit_weixin_Fn: function (e) {
    var a = this,
      i = e.detail.value.weixin;
    o.ifweixin(i)
      ? ((t = wx.getStorageSync("COOK_U")),
        o.ajax({
          url: "my_cert.php",
          data: { submitok: "weixin_update", weixin: i, openid: t.openid },
          success: function (t) {
            1 == t.flag
              ? a.setData({ kefu_weixin: !0, kfARR: t.kfARR })
              : wx.showModal({
                  content: t.msg,
                  confirmColor: a.data.color,
                  confirmText: "朕知道了",
                  showCancel: !1,
                  success: function (t) {},
                });
          },
        }))
      : wx.showToast({
          title: "请输入正确的【微信号】",
          icon: "none",
          mask: !0,
        });
  },
  kefu_weixin_closeFn: function () {
    this.setData({ kefu_weixin: !1 }), wx.navigateBack();
  },
  submit_mob_Fn: function (e) {
    var i = this,
      n = e.detail.value.mob,
      s = e.detail.value.verify;
    a.ifmob(n)
      ? a.ifint(s)
        ? ((t = wx.getStorageSync("COOK_U")),
          o.ajax({
            url: "my_cert.php",
            data: {
              submitok: "ajax_cert_mob_addupdate",
              mob: n,
              ss: i.data.ss,
              verify: s,
              openid: t.openid,
            },
            success: function (t) {
              1 == t.flag
                ? (wx.showToast({ title: t.msg, mask: !0, duration: 3e3 }),
                  setTimeout(function () {
                    wx.navigateBack();
                  }, 3e3))
                : wx.showModal({
                    content: t.msg,
                    confirmColor: i.data.color,
                    confirmText: "朕知道了",
                    showCancel: !1,
                    success: function (t) {},
                  });
            },
          }))
        : wx.showToast({
            title: "请输入正确的【短信验证码】",
            icon: "none",
            mask: !0,
          })
      : wx.showToast({
          title: "请输入正确的【手机号码】",
          icon: "none",
          mask: !0,
        });
  },
  submit_mob3_Fn: function (e) {
    var i = e.detail.value.mob,
      n = e.detail.value.truename,
      s = e.detail.value.identitynum,
      c = this;
    a.ifmob(i)
      ? a.empty(n)
        ? wx.showToast({ title: "请输入【真实姓名】", icon: "none", mask: !0 })
        : a.ifsfz(s)
        ? wx.showModal({
            title: "温馨提醒",
            content: c.data.showModalC,
            confirmColor: c.data.color,
            cancelText: "取消",
            confirmText: "确定提交",
            success: function (e) {
              if (e.confirm) {
                var a = parseFloat(c.data.ARR.price),
                  l = {
                    submitok: "identity_mob3_update",
                    mob: i,
                    truename: n,
                    identitynum: s,
                    openid: t.openid,
                  };
                a > 0
                  ? o.pay({
                      data: { submitok: "my_cert", f: "identity" },
                      success: function () {
                        c.submit_mob3_Fn_public(l);
                      },
                      fail: function () {
                        console.log("支付失败");
                      },
                    })
                  : c.submit_mob3_Fn_public(l);
              }
            },
          })
        : wx.showToast({
            title: "请输入正确的【身份证号码】",
            icon: "none",
            mask: !0,
          })
      : wx.showToast({
          title: "请输入正确的【手机号码】",
          icon: "none",
          mask: !0,
        });
  },
  submit_mob3_Fn_public: function (t) {
    var e = this;
    o.ajax({
      url: "my_cert.php",
      data: t,
      success: function (t) {
        1 == t.flag
          ? (wx.showToast({ title: t.msg, mask: !0, duration: 3e3 }),
            setTimeout(function () {
              wx.navigateBack();
            }, 3e3))
          : wx.showModal({
              title: t.title,
              content: t.msg,
              confirmColor: e.data.color,
              confirmText: "朕知道了",
              showCancel: !1,
              success: function (t) {
                wx.navigateBack();
              },
            });
      },
    });
  },
  sfz1Fn: function () {
    if (0 == this.data.ARR.rzflag) {
      var t = this;
      wx.chooseMedia({
        count: 1,
        mediaType: ["image"],
        sourceType: ["album", "camera"],
        sizeType: ["compressed"],
        success: function (a) {
          var o;
          t.setData(
            (e((o = {}), "ARR.sfz1", a.tempFiles[0].tempFilePath),
            e(o, "tmpsfz[0]", a.tempFiles[0].tempFilePath),
            o)
          );
        },
      });
    } else wx.showToast({ title: "请等待审核", icon: "none", mask: !0 });
  },
  sfz2Fn: function () {
    if (0 == this.data.ARR.rzflag) {
      var t = this;
      wx.chooseMedia({
        count: 1,
        mediaType: ["image"],
        sourceType: ["album", "camera"],
        sizeType: ["compressed"],
        success: function (a) {
          var o;
          t.setData(
            (e((o = {}), "ARR.sfz2", a.tempFiles[0].tempFilePath),
            e(o, "tmpsfz[1]", a.tempFiles[0].tempFilePath),
            o)
          );
        },
      });
    } else wx.showToast({ title: "请等待审核", icon: "none", mask: !0 });
  },
  submit_identity_Fn: function (e) {
    var i = e.detail.value.truename,
      n = e.detail.value.identitynum,
      s = this;
    if (a.empty(i))
      wx.showToast({ title: "请输入【真实姓名】", icon: "none", mask: !0 });
    else if (a.ifsfz(n))
      if (a.empty(this.data.tmpsfz[0]) || a.empty(this.data.tmpsfz[1]))
        wx.showToast({ title: "请上传【身份证照片】", icon: "none", mask: !0 });
      else {
        var c = {
          submitok: "identity_update",
          truename: i,
          identitynum: n,
          openid: t.openid,
        };
        wx.uploadFile({
          url: o.WWW + "/api/wxxcx/my_cert.php",
          filePath: s.data.tmpsfz[0],
          name: "pic0",
          formData: c,
          success: function (t) {
            1 == (t = a.jsoneval(t.data)).flag
              ? wx.uploadFile({
                  url: o.WWW + "/api/wxxcx/my_cert.php",
                  filePath: s.data.tmpsfz[1],
                  name: "pic1",
                  formData: c,
                  success: function (t) {
                    1 == (t = a.jsoneval(t.data)).flag
                      ? (wx.showToast({
                          title: t.msg,
                          mask: !0,
                          duration: 3e3,
                        }),
                        setTimeout(function () {
                          wx.navigateBack();
                        }, 3e3))
                      : wx.showModal({
                          content: t.msg,
                          confirmColor: s.data.color,
                          confirmText: "朕知道了",
                          showCancel: !1,
                          success: function (t) {},
                        });
                  },
                })
              : wx.showModal({
                  content: t.msg,
                  confirmColor: s.data.color,
                  confirmText: "朕知道了",
                  showCancel: !1,
                  success: function (t) {},
                });
          },
        });
      }
    else
      wx.showToast({
        title: "请输入正确的【身份证号码】",
        icon: "none",
        mask: !0,
      });
  },
  submit_photo_Fn: function (t) {
    var e = t.detail.value.truename,
      i = t.detail.value.identitynum,
      n = this;
    a.empty(e)
      ? wx.showToast({ title: "请输入【真实姓名】", icon: "none", mask: !0 })
      : a.ifsfz(i)
      ? wx.showModal({
          title: "温馨提醒",
          content:
            "请【平视镜头】保持【光线明亮】\n\n请勿戴帽子，摇头等动作幅度不能大\n\n动作缓慢，否则会检测不到人脸失败",
          confirmColor: n.data.color,
          cancelText: "取消",
          confirmText: "开始核验",
          success: function (t) {
            t.confirm &&
              (parseFloat(n.data.ARR.price) > 0
                ? o.pay({
                    data: { submitok: "my_cert", f: "photo" },
                    success: function () {
                      wx.navigateTo({
                        url: "cert_face?truename=" + e + "&identitynum=" + i,
                      });
                    },
                    fail: function () {
                      console.log("支付失败");
                    },
                  })
                : wx.navigateTo({
                    url: "cert_face?truename=" + e + "&identitynum=" + i,
                  }));
          },
        })
      : wx.showToast({
          title: "请输入正确的【身份证号码】",
          icon: "none",
          mask: !0,
        });
  },
  onShow: function () {
    2 == getCurrentPages().length && this.data.ifonLoad && this.index();
  },
  kefuFn: function () {
    this.setData({ kefu: !0 });
  },
  kefu_closeFn: function () {
    this.setData({ kefu: !1 });
  },
  elseupFn: function () {
    var t = this;
    0 == this.data.ARR.rzflag
      ? (t.setData({ ifonLoad: !1 }),
        wx.chooseMedia({
          count: 1,
          mediaType: ["image"],
          sourceType: ["album", "camera"],
          sizeType: ["compressed"],
          success: function (a) {
            var o;
            t.setData(
              (e((o = {}), "ARR.path_b", a.tempFiles[0].tempFilePath),
              e(o, "elsetmp", a.tempFiles[0].tempFilePath),
              o)
            );
          },
        }))
      : wx.showToast({ title: "请等待审核", icon: "none", mask: !0 });
  },
  elsebtnFn: function () {
    var e = this;
    if (a.empty(e.data.elsetmp))
      wx.showToast({ title: "请上传认证照片", icon: "none", mask: !0 });
    else {
      var i = { submitok: "else_update", f: e.data.f, openid: t.openid };
      wx.uploadFile({
        url: o.WWW + "/api/wxxcx/my_cert.php",
        filePath: e.data.ARR.path_b,
        name: "pic",
        formData: i,
        success: function (t) {
          1 == (t = a.jsoneval(t.data)).flag
            ? (wx.showToast({ title: t.msg, mask: !0, duration: 3e3 }),
              setTimeout(function () {
                wx.navigateBack();
              }, 3e3))
            : wx.showModal({
                content: t.msg,
                confirmColor: e.data.color,
                confirmText: "朕知道了",
                showCancel: !1,
                success: function (t) {
                  wx.navigateBack();
                },
              });
        },
      });
    }
  },
  onShareAppMessage: function () {
    return { imageUrl: "", title: "诚信认证", path: "/pages/cert/cert" };
  },
});
